# -*- encoding:UTF-8 -*-

import time
import os

file = open("demo.txt","w")
print "文件名:",file.name
print "文件是否已经关闭:",file.closed
print "文件访问模式:",file.mode
print "文件末尾是否强制加空格:",file.softspace

writeStr = "新加入的内容    ".__add__(str(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())).__add__("\n"))
file.write(writeStr)
file.close()

file = open("demo.txt","r+")
print "当前指针位置",file.tell()
content = file.read(20)
print "文件内容:"
print "当前指针位置",file.tell()
position = file.seek(0,0)
print "当前指针位置",file.tell()
content = file.read()
print "文件内容:"
print content
file.close()

if not os.path.exists("test"):
    os.mkdir("test")
print os.getcwd()
if os.path.exists("test"):
    os.rmdir("test")
